home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / boekhoud / finan / BADGER finance v1.0 beta 2.exe / xampplite / phpMyAdmin / libraries / select_server.lib.php < prev    next >
PHP Script  |  2006-02-16  |  4KB  |  118 lines

  1. <?php
  2. /*
  3.  * Code for displaying server selection written by nijel
  4.  * $Id: select_server.lib.php,v 2.10.2.3 2006/02/17 09:46:49 cybot_tm Exp $
  5.  */
  6.  
  7. /**
  8.  * display server selection in list or selectbox form, or option tags only
  9.  *
  10.  * @todo    make serverlist a real html-list
  11.  * @globals $lang
  12.  * @globals $convcharset
  13.  * @uses    $GLOBALS['cfg']['DisplayServersList']
  14.  * @uses    $GLOBALS['strServer']
  15.  * @uses    $GLOBALS['cfg']['Servers']
  16.  * @uses    $GLOBALS['strGo']
  17.  * @uses    implode()
  18.  * @uses    htmlspecialchars()
  19.  * @param   boolean $not_only_options   whether to include form tags or not
  20.  * @param   boolean $ommit_fieldset     whether to ommit fieldset tag or not
  21.  */
  22. function PMA_select_server($not_only_options, $ommit_fieldset)
  23. {
  24.     global $lang, $convcharset;
  25.  
  26.     // Show as list?
  27.     if ($not_only_options) {
  28.         $list = $GLOBALS['cfg']['DisplayServersList'];
  29.         $not_only_options =! $list;
  30.     } else {
  31.         $list = false;
  32.     }
  33.  
  34.     if ($not_only_options) {
  35.         echo '<form method="post" action="index.php" target="_parent">';
  36.  
  37.         if (! $ommit_fieldset) {
  38.             echo '<fieldset>';
  39.         }
  40.         echo '<label for="select_server">' . $GLOBALS['strServer'] . ':</label> ';
  41.  
  42.         echo '<select name="server" id="select_server"'
  43.             . ' onchange="if (this.value != \'\') this.form.submit();">';
  44.         // TODO FIXME replace with $GLOBALS['strServers']
  45.         echo '<option value="">(' . $GLOBALS['strServer'] . ') ...</option>' . "\n";
  46.     } elseif ($list) {
  47.         echo $GLOBALS['strServer'] . ':<br />';
  48.         // TODO FIXME display server list as 'list'
  49.         // echo '<ol>';
  50.     }
  51.  
  52.     foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
  53.         if (empty($server['host'])) {
  54.             continue;
  55.         }
  56.  
  57.         if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
  58.             $selected = 1;
  59.         } else {
  60.             $selected = 0;
  61.         }
  62.  
  63.         if (!empty($server['verbose'])) {
  64.             $label = $server['verbose'];
  65.         } else {
  66.             $label = $server['host'];
  67.             if (!empty($server['port'])) {
  68.                 $label .= ':' . $server['port'];
  69.             }
  70.         }
  71.         // loic1: if 'only_db' is an array and there is more than one
  72.         //        value, displaying such informations may not be a so good
  73.         //        idea
  74.         if (!empty($server['only_db'])) {
  75.             // TODO FIXME this can become a really big/long/wide selectbox ...
  76.             $label .= ' - ' . (is_array($server['only_db']) ? implode(', ', $server['only_db']) : $server['only_db']);
  77.         }
  78.         if (!empty($server['user']) && $server['auth_type'] == 'config') {
  79.             $label .= '  (' . $server['user'] . ')';
  80.         }
  81.  
  82.         if ($list) {
  83.             // TODO FIXME display server list as 'list'
  84.             // echo '<li>';
  85.             if ($selected && !$ommit_fieldset) {
  86.                 echo '» <b>' . htmlspecialchars($label) . '</b><br />';
  87.             } else {
  88.                 echo '» <a class="item" href="index.php?server=' . $key . '&lang=' . $lang . '&convcharset=' . $convcharset . '" target="_top">' . htmlspecialchars($label) . '</a><br />';
  89.             }
  90.             // echo '</li>';
  91.         } else {
  92.             echo '            <option value="' . $key . '" ' . ($selected ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>' . "\n";
  93.         }
  94.     } // end while
  95.  
  96.     if ($not_only_options) {
  97.         echo '</select>';
  98.         if ($ommit_fieldset) {
  99.             echo '<hr />';
  100.         } else {
  101.             echo '</fieldset>';
  102.         }
  103.         ?>
  104.         <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  105.         <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
  106.         <?php
  107.         // Show submit button if we have just one server (this happens with no default)
  108.         echo '<noscript>';
  109.         echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
  110.         echo '</noscript>';
  111.         echo '</form>';
  112.     } elseif ($list) {
  113.         // TODO FIXME display server list as 'list'
  114.         // echo '</ol>';
  115.     }
  116. }
  117. ?>
  118.